// 工具
import { isNull, clog } from '/@/utils/index';
import MkDrawer from '/@/componentsMaike/container/MkDrawer.vue';


export function useEditScripts<T>() {
	const ctx = reactive({
		isEdit: false,
	});
	const addBillNo = () => {
		alert('触发新增成功');
	};

	const mkDrawerRef = ref<InstanceType<typeof MkDrawer>>();
	// 打开弹窗
	const openDrawerFn = async (row: T) => {
		mkDrawerRef.value?.show();
	};
	// 关闭弹窗
	const closeDrawerFn = async () => {
		mkDrawerRef.value?.close();
	};

	// 提交
	const submitFn = async () => {
		alert('保存成功，待补充');
		if (!ctx.isEdit) {
			closeDrawerFn();
			return;
		}
	};

	return {
		...toRefs(ctx),
		openDrawerFn, // 打开弹窗
		closeDrawerFn, // 关闭弹窗
		submitFn,
		mkDrawerRef, //弹框组件引用
    addBillNo, // 成功回调
	};
}
